<template>
  <div class="container">
    <view class="user flex alignCenter" @click="proxy.$utils.toLink(`/packagePages/user/details?id=${info.userId}`)">
      <uv-avatar :src="info.logo" mode="aspectFill" size="60"></uv-avatar>
      <view class="user-info flex alignCenter justifyBetween">
        <view>
          <view class="name bold">{{info.nickName}}</view>
          <view class="fz12" style="padding:3px 0">{{info.city}}·{{info.homeEconomize}}</view>
          <view class="fz12 desc">{{info.ageYear}}·{{info.constellation}}</view>
        </view>
        <uv-icon name="arrow-right" size="21" bold @click="proxy.$utils.back()"></uv-icon>
      </view>
    </view>

    <view class="content fz14">{{remark}}</view>

    <view class="actionBtn flex justifyBetween" v-if="type==0">
      <view class="btn" @click="refuse">
        <uv-button text="拒绝" color="#F9F6F9" :customTextStyle="{color: '#191720'}"></uv-button>
      </view>
      <view class="btn" @click="accept">
        <uv-button text="同意" color="#B087F2"></uv-button>
      </view>
    </view>
  </div>
</template>

<script setup lang="ts">
import YeIMStore from "@/stores/YeIM";
const YeIM = YeIMStore();

const { proxy } = getCurrentInstance();
import useCounterStore from "@/stores/counter";
const counter = useCounterStore();
const instance = getCurrentInstance();

let info = ref({});
let userId;
let remark = ref("");
let type = ref(null);

onLoad((e) => {
  userId = e.userId;
  remark.value = e.remark;
  type.value = e.type;
  getInfo();
});

async function getInfo() {
  info.value = await counter.getUserInfo(userId);
  console.log("用户信息", info.value);
}

async function accept() {
  let resp = await proxy.$utils.showModal({
    content: "是否确认同意该好友申请？",
    confirmColor: "#B087F2",
  });
  if (!resp) return;
  await YeIM.acceptApply(userId);
  await proxy.$utils.showToast("同意成功");
  proxy.$utils.back();
}

async function refuse() {
  let resp = await proxy.$utils.showModal({
    content: "是否确认拒绝该好友申请？",
    confirmColor: "#B087F2",
  });
  if (!resp) return;
  await YeIM.refuseApply(userId);
  await proxy.$utils.showToast("拒绝成功");
  proxy.$utils.back();
}
</script>



<style lang="scss" scoped>
.container {
  padding: 10px 15px;
  .user {
    .user-info {
      margin-left: 10px;
      width: 100%;
      .desc {
        color: #999;
      }
    }
  }
  .content {
    background-color: #f9f6f9;
    border-radius: 10px;
    padding: 15px 10px;
    margin-top: 20px;
  }
  .actionBtn {
    // position: fixed;
    // bottom: 30px;
    // left: 0;
    // right: 0;
    margin: 100px auto 0;
    width: calc(100% - 30px);
    .btn {
      width: calc((100% - 20px) / 2);
    }
  }
}
</style>



